#!/bin/bash


AUDIT_DIR="cpas-workplatform-audit"
FRAMEWORK_DIR="framework"

# Step 1 走标签发版方式
# echo "Step 1: Executing publish.sh script..."
# ./publish.sh
# echo "Step 1 completed."

#Step 1 本地测试方式
#echo "Step 1: 打包cpas-business组件库中...."
#git pull
#if [ $1 -eq 'git' ]
#then
#    echo "git logic"
#else
#   # 先重名名再拷贝
#   mv ./cpas-business ./cpas-business-auto-bak
#fi
#npm run build
#echo "组件库打包完毕"

Step 2
echo "Step 2: 打包audit中..."
#cd ../$AUDIT_DIR
git pull
#rm -rf ./public/cpas-business
#cp -rf ../cpas-lib-business/cpas-business ./public
npm run auditBuild
echo "audit项目打包完毕"

#if [ $1 -eq 'git' ]
#then
#   echo "git logic"
#else
#   # 还原audit
#   rm -rf ../cpas-lib-business/cpas-business
#   mv ../cpas-lib-business/cpas-business-auto-bak ../cpas-lib-business/cpas-business
#fi

# Step 3
echo "Step 3: audit包导入到freamwork中..."
cd ../$FRAMEWORK_DIR
git pull
if [ $1 -eq 'git' ]
then
   rm -rf ./webapps/cpas-cloud/audit
else
   # 先重名名再拷贝
   mv ./webapps/cpas-cloud/audit ./audit-auto-bak
fi

cp -rf ../$AUDIT_DIR/audit ./webapps/cpas-cloud
echo "audit包导入到freamwork中完毕"

# Step 4
echo "Step 4: 打包增量包中..."
npm run cpas6-release
echo "打包增量包完毕"

if [ $1 -eq 'git' ]
then
   echo "git logic"
else
   rm -rf ./webapps/cpas-cloud/audit
   # 还原audit
   mv ./audit-auto-bak ./webapps/cpas-cloud/audit
fi

echo "整体打包完成"
